//
//  QDCaseManagerCell2.m
//  QuickDoctor
//
//  Created by ycw on 2016/12/25.
//  Copyright © 2016年 Eric. All rights reserved.
//

#import "QDCaseManagerCell2.h"
#import "QDCaseModel.h"

@implementation QDCaseManagerCell2
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpUI];
        
    }
    
    return self;
}

#pragma mark
#pragma mark - 设置cell
- (void) setUpUI
{
    
    UIImageView *leftImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"illness_rb_img_sel.png"]];
    
    [self.contentView addSubview:leftImg];
    
    [leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.top.equalTo(self.contentView).mas_offset(10);
        
        make.height.width.mas_equalTo(10);
        
    }];
    
    UIView *line = [[UIView alloc] init];
    
    [self.contentView addSubview:line];
    
    line.backgroundColor = [UIColor colorWithRed:101/255.0 green:209/255.0 blue:208/255.0 alpha:1];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.width.mas_equalTo(1);
        
        make.height.mas_equalTo(150);
        
        make.top.equalTo(leftImg.mas_bottom);
        
        make.bottom.equalTo(self.contentView);
        
        make.centerX.equalTo(leftImg);
        
    }];
    
    
    UILabel *lblTime = [[UILabel alloc] init];
    
    lblTime.textColor = [UIColor colorWithRed:142/255.0 green:142/255.0 blue:148/255.0 alpha:1];
    
    lblTime.font = [UIFont systemFontOfSize:15];
    
    [self.contentView addSubview:lblTime];
    
    self.lblTime = lblTime;
    
    [lblTime mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(leftImg);
        
        make.leading.equalTo(leftImg.mas_trailing).mas_offset(10);
        
        make.trailing.equalTo(self.contentView).mas_offset(-10);
        
        make.height.mas_equalTo(18);
        
    }];
    
    UIImageView *iconImg = [[UIImageView alloc] init];
    
    [self.contentView addSubview:iconImg];
    
    self.iconImg = iconImg;
    
    [iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(line.mas_trailing).mas_offset(15);
        
        make.top.equalTo(lblTime.mas_bottom).mas_offset(10);
        
        make.height.width.mas_equalTo(80);
        
    }];
    
    UILabel *label1 = [[UILabel alloc] init];
    
    label1.text = @"疾病类型:";
    
    [self.contentView addSubview:label1];
    
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lblTime.mas_bottom).mas_offset(10);
        
        make.leading.equalTo(iconImg.mas_trailing).mas_offset(20);
        
        make.width.mas_equalTo(80);
        
    }];
    
    UILabel *label2 = [[UILabel alloc] init];
    
    label2.text = @"基本类型:";
    
    [self.contentView addSubview:label2];
    
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(label1.mas_bottom).mas_offset(10);
        
        make.leading.equalTo(label1);
        
        make.width.mas_equalTo(80);
        
    }];
    
    UILabel *lblCase = [[UILabel alloc] init];
    
    [self.contentView addSubview:lblCase];
    
    self.lblCase = lblCase;
    
    lblCase.textColor = [UIColor colorWithRed:142/255.0 green:142/255.0 blue:148/255.0 alpha:1];
    
    lblCase.font = [UIFont systemFontOfSize:15];
    
    [lblCase mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(label1);
        
        make.leading.equalTo(label1.mas_trailing).mas_offset(5);
        
        make.trailing.equalTo(self.contentView).mas_offset(-10);
        
        make.height.mas_equalTo(18);
        
    }];
    
    UILabel *lblSub = [[UILabel alloc] init];
    
    [self.contentView addSubview:lblSub];
    
    self.lblSub = lblSub;
    
    lblSub.textColor = [UIColor colorWithRed:142/255.0 green:142/255.0 blue:148/255.0 alpha:1];
    
    lblSub.font = [UIFont systemFontOfSize:15];
    
    [lblSub mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(label2);
        
        make.leading.equalTo(label2.mas_trailing).mas_offset(5);
        
        make.trailing.equalTo(self.contentView).mas_offset(-10);
        
        make.height.mas_equalTo(18);
        
    }];
    
    UILabel *lblText = [[UILabel alloc] init];
    
    [self.contentView addSubview:lblText];
    
    self.lblText = lblText;
    
    lblText.numberOfLines = 0;
    
    lblText.textColor = [UIColor colorWithRed:142/255.0 green:142/255.0 blue:148/255.0 alpha:1];
    
    lblText.font = [UIFont systemFontOfSize:15];
    
    [lblText mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(label2.mas_bottom).mas_offset(10);
        
        make.leading.equalTo(label2);
        
        make.trailing.equalTo(self.contentView).mas_offset(-10);
        
        make.height.mas_equalTo(60);
        
    }];
    
}

- (void)setModel:(QDCaseModel *)model
{
    
    _model = model;
    
    self.lblTime.text = model.illnessTime;
    
    self.lblCase.text = model.illnessType;
    
    self.lblSub.text = model.illnessSub;
    
    self.lblText.text = model.illnessDesc;
    
    self.iconImg.image = [UIImage imageWithData:model.illnessImage];
    
}
@end

